﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Disk
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
        }

        //登录页面加载事件
       public static firstpage firstpage = new firstpage();
        public static findcode findcode = new findcode();
        public static register register = new register();
        private void login_Load(object sender, EventArgs e)
        {
            //加载时焦点在账号框
            textBox1.Focus();
        }
        //退出系统
        private void login_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }
        //注册点击事件
        private void linkLabel1_Click(object sender, EventArgs e)
        {
            register.Show();
            this.Hide();
        }

        //登录点击事件
        private void Rebutton_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                if (textBox2.Text != "")
                {
                    string username = textBox1.Text;
                    string password = textBox2.Text;
                 
                    int num = 3;
                    if (num==3)
                    {
                        MessageBox.Show("登录成功，进入首页");
                        new Thread(() => {
                            Application.Run(firstpage);
                        }).Start();
                        this.Close();
                    }
                    if (num==0)
                    {
                        MessageBox.Show("无此用户,请重新输入");
                    }
                    if (num==1)
                    {
                        MessageBox.Show("用户名错误");
                    }
                    if (num == 2)
                    {
                        MessageBox.Show("密码错误");
                    }

                }
                else if (textBox2.Text == "")
                {
                    textBox2.Focus();
                    MessageBox.Show("请输入密码");
                }
            }
            else if (textBox1.Text == "")
            {
                textBox1.Focus();
                MessageBox.Show("请输入账号");
            }
        }
        //找回密码窗体单击事件
        private void linkLabel2_Click(object sender, EventArgs e)
        {
            findcode.Show();
            this.Hide();
        }

        private void login_Load_1(object sender, EventArgs e)
        {

        }
    }
}
